package com.hfzy.ihk.facade.linkcall.entity.flow.config;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hfzy.ihk.common.facade.BaseEntity;
import com.hfzy.ihk.common.facade.entity.KeyValueField;
import com.hfzy.ihk.common.facade.enums.CustomerNeedLevel;
import com.hfzy.ihk.facade.linkcall.enums.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018/7/19.
 * 话术（是树的节点）
 *
 * 增加公用节点: 公用节点===》指每个流程节点都可以跳转到到该节点，是不属于流程也不属于话术包的，通用的节点，可以避免创建多个相同的节点数据
 * 公用节点中的 packageId、flowId 为空情况
 * @author wws
 */
@Document(indexName = "#{elasticSearchConfig.indexName()}_flow_step", shards = 24, replicas = 2, type = "data")
public class SpeakingFlowStep implements BaseEntity {

    @Id
    @Field(type = FieldType.Keyword)
    private String id;

    private long version;

    /**属于哪个话术流程*/
    @Field(type = FieldType.Keyword)
    private String flowId;


    /**属于哪个话术包*/
    @Field(type = FieldType.Keyword)
    private String packageId;
    /**经纪的意图*/
    @Field(type = FieldType.Keyword)
    private String stepName;

    /**话术类型*/
    @Field(type = FieldType.Keyword)
    private SpeakingFlowStepType type;

    /**
     * 话术/跳转前话术
     */
    @Field(type = FieldType.Text)
    private String content;

    /**客户回答类型,回答分支,多个*/
    /**
     * 内嵌字段将会创建一个隐藏的表
     * 如果对象内的字段间不需要强的关联关系，使用object就好
     */
    @Field(type = FieldType.Nested)
    private List<KeyValueField> answerTypes; //用户回答类型 key typeVal val typedesc

    /**
     private List<CustomerAnswerType> customerAnswerType;
     客户特殊回答内容(比如提问)
     @Field(type = FieldType.Text)
     private String customerSpecialContent;*/

/*----------------------暂留，看看是否需要双向链表-------------------------*/
    /**上一级话术Id*/
    /*TODO 这里不够用，一个节点的前面可能有2个或以上节点（目前还不需要，暂留）*/
    @Field(type = FieldType.Keyword)
    private String preNodeId;
    /**上一级话术客户回答类型*/
    @Field(type = FieldType.Keyword)
    private CustomerAnswerWay preNodeAnswerType;
/*----------------------暂留，看看是否需要双向链表-------------------------*/

    /** key 回答类型的key val 该回答指向的流程id*/
    @Field(type = FieldType.Nested)
    private List<KeyValueField> answerTypeRelation;

    /**跳转方式：用于主流程*/
    @Field(type = FieldType.Keyword)
    private SpeakingFlowSkipType skipType;

    /**跳转方式：多轮会话使用这个*/
    private AfterAnswerOptionalType mutiSessionSkipType;

    /**跳转到指定流程*/
    private String skipFlowId;

    /**跳转到指定流程节点*/
    private String skipFlowStepId;

    /**话术的录音文件*/
    private String recordFileUrl;

    /**能否中断*/
    private boolean canInterrupt;
    /**是否需要发短信*/
    private boolean needSendMessage;

    private long createUserId;

    private CustomerNeedLevel customerNeedLevel;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date modTime;

    //当前所在的坐标 用于绘图
    private String x;
    private String y;

    /**是否已上传了录音文件 === 》 如果content(话术) 为空情况下，无须进行上传录音文件*/
    private boolean hadUploadFile = false;

    /**是否流程下的第一个步骤*/
    private boolean firstStepByFlow = false;

    /**录音对应的Code 值*/
    private String recordCodeNum;

    private boolean actionCodeBreak = false;//是否可以打断

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    public String getStepName() {
        return stepName;
    }

    public void setStepName(String stepName) {
        this.stepName = stepName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getFlowId() {
        return flowId;
    }

    public void setFlowId(String flowId) {
        this.flowId = flowId;
    }

    public SpeakingFlowStepType getType() {
        return type;
    }

    public void setType(SpeakingFlowStepType type) {
        this.type = type;
    }


    public String getPreNodeId() {
        return preNodeId;
    }

    public void setPreNodeId(String preNodeId) {
        this.preNodeId = preNodeId;
    }


    public CustomerAnswerWay getPreNodeAnswerType() {
        return preNodeAnswerType;
    }

    public void setPreNodeAnswerType(CustomerAnswerWay preNodeAnswerType) {
        this.preNodeAnswerType = preNodeAnswerType;
    }

    public long getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(long createUserId) {
        this.createUserId = createUserId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModTime() {
        return modTime;
    }

    public void setModTime(Date modTime) {
        this.modTime = modTime;
    }

    public boolean isCanInterrupt() {
        return canInterrupt;
    }

    public void setCanInterrupt(boolean canInterrupt) {
        this.canInterrupt = canInterrupt;
    }

    public boolean isNeedSendMessage() {
        return needSendMessage;
    }

    public void setNeedSendMessage(boolean needSendMessage) {
        this.needSendMessage = needSendMessage;
    }

    public SpeakingFlowSkipType getSkipType() {
        return skipType;
    }

    public void setSkipType(SpeakingFlowSkipType skipType) {
        this.skipType = skipType;
    }

    public String getSkipFlowId() {
        return skipFlowId;
    }

    public void setSkipFlowId(String skipFlowId) {
        this.skipFlowId = skipFlowId;
    }

    public AfterAnswerOptionalType getMutiSessionSkipType() {
        return mutiSessionSkipType;
    }

    public void setMutiSessionSkipType(AfterAnswerOptionalType mutiSessionSkipType) {
        this.mutiSessionSkipType = mutiSessionSkipType;
    }

    public CustomerNeedLevel getCustomerNeedLevel() {
        return customerNeedLevel;
    }

    public void setCustomerNeedLevel(CustomerNeedLevel customerNeedLevel) {
        this.customerNeedLevel = customerNeedLevel;
    }


    public List<KeyValueField> getAnswerTypes() {
        return answerTypes;
    }

    public void setAnswerTypes(List<KeyValueField> answerTypes) {
        this.answerTypes = answerTypes;
    }

    public List<KeyValueField> getAnswerTypeRelation() {
        return answerTypeRelation;
    }

    public void setAnswerTypeRelation(List<KeyValueField> answerTypeRelation) {
        this.answerTypeRelation = answerTypeRelation;
    }

    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }

    public String getY() {
        return y;
    }

    public void setY(String y) {
        this.y = y;
    }

    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }

    public String getSkipFlowStepId() {
        return skipFlowStepId;
    }

    public void setSkipFlowStepId(String skipFlowStepId) {
        this.skipFlowStepId = skipFlowStepId;
    }

    public String getRecordFileUrl() {
        return recordFileUrl;
    }

    public void setRecordFileUrl(String recordFileUrl) {
        this.recordFileUrl = recordFileUrl;
    }

    public boolean getHadUploadFile() {
        return hadUploadFile;
    }

    public void setHadUploadFile(boolean hadUploadFile) {
        this.hadUploadFile = hadUploadFile;
    }

    public boolean isFirstStepByFlow() {
        return firstStepByFlow;
    }

    public void setFirstStepByFlow(boolean firstStepByFlow) {
        this.firstStepByFlow = firstStepByFlow;
    }

    public String getRecordCodeNum() {
        return recordCodeNum;
    }

    public void setRecordCodeNum(String recordCodeNum) {
        this.recordCodeNum = recordCodeNum;
    }

    public boolean isActionCodeBreak() {
        return actionCodeBreak;
    }

    public void setActionCodeBreak(boolean actionCodeBreak) {
        this.actionCodeBreak = actionCodeBreak;
    }
}
